<%@page import="dao.impl.McTypeDAOImpl"%>
<%@page import="bean.McTypeBean"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	System.out.println(path);
	String basePath = request.getScheme() + "://"
	+ request.getServerName() + ":" + request.getServerPort()
	+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'adminType.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<style type="text/css">
#smallType input {
	width: 100px;
}

#bigType input {
	width: 100px;
	float: left;
}
</style>
<link rel="stylesheet" href="<%=path%>/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="<%=path%>/bootstrap/css/bootstrap-theme.min.css" />
<script src="<%=path%>/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/row_crud.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery.min.js"></script>
</head>
<body  style="margin-top: 30px">
	<!-- <div class="" style="margin: 10px 20px;">
		<input type="text" name="querynid" style="width: 109px; "><input
			type="button" value="查询编号" onclick="javascript:window.location.href='McTypeServlet?task=queryNid'"> <input
			type="text" name="querysname" style="width: 144px; "><input
			type="button" value="查询名称" onclick="javascript:window.location.href='McTypeServlet?task=querySname'"> <input
			type="text" name="querynpid" ><input
			type="button" value="查询小类" onclick="javascript:window.location.href='McTypeServlet?task=queryNpid'">
	</div> -->
	<div class="col-md-6" >
		<form>
			<table class="table table-condensed" id="order" border="1"
				style="width: 686px;">
				<thead>
					<tr class="">
						<td class="text-center">编号</td>
						<td class="text-center">类别名称</td>
						<td class="text-center">所属父类</td>
						<td class="text-center">操作&nbsp; <a href="admin/addType.jsp">添加</a></td>
					</tr>
				</thead>
				<%
					//String ope = request.getParameter("ope");
							McTypeDAOImpl typeCRUDImpl = new McTypeDAOImpl();
							List<McTypeBean> allTypes = typeCRUDImpl.queryByNpid(0);
							int i = 0;
							for (McTypeBean mcTypeBean : allTypes) {
								List<McTypeBean> allSmallTypes = typeCRUDImpl
										.queryByNpid(mcTypeBean.getNid());
								i++;
				%>
				<tr id="bigType">
					<td><input value="<%=mcTypeBean.getNid()%>" name="nid"
						readonly="readonly"></td>
					<td><input value="<%=mcTypeBean.getSname()%>" name="sname"
						readonly="readonly"></td>
					<td><input value="<%=mcTypeBean.getNpid()%>" name="npid"
						readonly="readonly"></td>
					<td><a href="javascript:;" onclick="upRow(this);">修改</a>&nbsp;&nbsp;
						<a href="javascript:;"
						onclick="delRow(this,<%=mcTypeBean.getNid()%>)">删除</a>&nbsp;&nbsp;&nbsp;&nbsp;
						<a href="javascript:;" onclick="show(this,<%=i%>)">收起</a></td>
				</tr>
				<tbody id="tbody<%=i%>">
					<%
						for (McTypeBean smallTypeBean : allSmallTypes) {
								System.out.println("smallTypeBean" + smallTypeBean);
					%>
					<tr id="smallType">
						<td class="text-center"><input
							value="<%=smallTypeBean.getNid()%>" name="nid"
							readonly="readonly"></td>
						<td class="text-center"><input
							value="<%=smallTypeBean.getSname()%>" name="sname"
							readonly="readonly"></td>
						<td class="text-center"><input
							value="<%=smallTypeBean.getNpid()%>" name="npid"
							readonly="readonly"></td>
						<td><a href="javascript:;" onclick="upRow(this);">修改</a>&nbsp;&nbsp;
							<a href="javascript:;"
							onclick="delRow(this,<%=smallTypeBean.getNid()%>)">删除</a></td>
					</tr>
					<%
						}
					%>
				</tbody>
				<%
					}
				%>
			</table>
			<div class="col-md-2" style="float: right">
				<input type="button" value="保存修改">
			</div>
		</form>
	</div>
</body>
</html>
